FROM docker.io/library/nginx:stable-alpine

# 切换为 root 用户修改权限
USER root

# 修改关键目录权限（兼容 OpenShift 非 root 执行）
RUN sed -i 's/listen       80;/listen       8080;/g' /etc/nginx/conf.d/default.conf \
 && chgrp -R 0 /usr/share/nginx/html \
 && chmod -R g=u /usr/share/nginx/html \
 && chgrp -R 0 /etc/nginx \
 && chmod -R g=u /etc/nginx \
 && chgrp -R 0 /var/cache/nginx \
 && chmod -R g=u /var/cache/nginx \
 && chgrp -R 0 /var/run \
 && chmod -R g=u /var/run

# 切回非特权用户（OpenShift 默认运行）
USER 1001

# 拷贝你的前端 dist 文件夹
COPY dist/ /usr/share/nginx/html

EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]
